package opendeck;
import java.util.*;

public abstract class Deck {
	
	ArrayList<Card> cards;
	
	Deck() {
		cards = new ArrayList<Card>();
	}
	
	public void shuffle() {
		Random randgen = new Random();
		int currentSize = cards.size();
		Card currentCard;
		ArrayList<Card> shuffledCards = new ArrayList<Card>();
		
		while (currentSize != 1) {
			int nextrand = randgen.nextInt(currentSize-1);
			currentCard = cards.get(nextrand);
			cards.remove(nextrand);
			shuffledCards.add(currentCard);
			currentSize--;
		}
		
		shuffledCards.add(cards.get(0));
		
		cards = shuffledCards;
		
	};
	
	public Card drawFirst() {
		Card card = cards.get(0);
		cards.remove(card);
		return card;}
	
	public Card drawLast() { 
		Card card = cards.get(cards.size());
		cards.remove(card);
		return card;
		}
	
	public int indexOf(Card c) {
		return cards.indexOf(c);
	}
	
	public int remainingCards() {
		return cards.size();
	}
	
	public boolean isEmpty() {
		return cards.isEmpty();
	}
	
}
